//
//  SDHSportsInteDetailCell.m
//  SDHSportsNews
//
//  Created by MichaelShan on 2021/3/8.
//

#import "SDHSportsInteDetailCell.h"
#import "SDHSportsWinRateView.h"

@interface SDHSportsInteDetailCell ()

@property (nonatomic, strong) UILabel *favContentLb;
@property (nonatomic, strong) UILabel *unfavContentLb;

@end

@implementation SDHSportsInteDetailCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUI];
    }
    
    return self;
}

- (void)setUI {
    self.contentView.backgroundColor = [UIColor blackColor];
    
    UIView *bgView = [UIView new];
    bgView.backgroundColor = [UIColor whiteColor];
    bgView.clipsToBounds = YES;
    bgView.layer.cornerRadius = 8;
    [self.contentView addSubview:bgView];
    
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView).insets(UIEdgeInsetsZero);
    }];
    
    UIImageView *imgView = [UIImageView new];
    imgView.image = [UIImage imageNamed:@"touxiang"];
    [bgView addSubview:imgView];
    self.avatarImg = imgView;
    
    UILabel *nameLb = [UILabel new];
    nameLb.textAlignment = NSTextAlignmentLeft;
    nameLb.textColor = [UIColor blackColor];
    nameLb.font = [UIFont boldSystemFontOfSize:14];
    [bgView addSubview:nameLb];
    nameLb.text = @"Burnley";
    self.nameLb = nameLb;
    
    UILabel *favoribleTitleLb = [UILabel new];
    favoribleTitleLb.textColor = leftTeamTitleColor;
    favoribleTitleLb.textAlignment = NSTextAlignmentLeft;
    favoribleTitleLb.font = [UIFont boldSystemFontOfSize:16];
    favoribleTitleLb.text = @"Favorible information";
    [bgView addSubview:favoribleTitleLb];
    
    UILabel *favContentLb = [UILabel new];
    favContentLb.textColor = [UIColor blackColor];
    favContentLb.textAlignment = NSTextAlignmentLeft;
    favContentLb.font = [UIFont systemFontOfSize:14];
    favContentLb.numberOfLines = 0;
    favContentLb.text = @"like you like you";
//    favContentLb.backgroundColor = [UIColor greenColor];
    [bgView addSubview:favContentLb];
    self.favContentLb = favContentLb;
    
    UILabel *unfavoribleTitleLb = [UILabel new];
    unfavoribleTitleLb.textColor = rightTeamTitleColor;
    unfavoribleTitleLb.textAlignment = NSTextAlignmentLeft;
    unfavoribleTitleLb.font = [UIFont boldSystemFontOfSize:16];
    unfavoribleTitleLb.text = @"Unfavorible information";
    [bgView addSubview:unfavoribleTitleLb];
    
    UILabel *unfavContentLb = [UILabel new];
    unfavContentLb.textColor = [UIColor blackColor];
//    unfavContentLb.backgroundColor = [UIColor greenColor];
    unfavContentLb.textAlignment = NSTextAlignmentLeft;
    unfavContentLb.font = [UIFont systemFontOfSize:14];
    unfavContentLb.numberOfLines = 0;
    unfavContentLb.text = @"hate you, hate you";
    [bgView addSubview:unfavContentLb];
    self.unfavContentLb = unfavContentLb;
    
//    unfavContentLb.backgroundColor = [UIColor blueColor];
    [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bgView).offset(15);
        make.top.equalTo(bgView).offset(5);
        make.width.equalTo(@50);
        make.height.equalTo(@50);
    }];
    
    [nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(imgView.mas_right).offset(10);
        make.top.equalTo(imgView.mas_top).offset(5);
        make.centerY.equalTo(imgView);
    }];
    
    [favoribleTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(imgView.mas_left);
        make.top.equalTo(imgView.mas_bottom).offset(5);
    }];
    
    [favContentLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(favoribleTitleLb);
        make.top.equalTo(favoribleTitleLb.mas_bottom).offset(8);
        make.right.equalTo(bgView).offset(-10);
    }];
    
    [unfavoribleTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(favoribleTitleLb);
        make.top.equalTo(favContentLb.mas_bottom).offset(10);
    }];
    
    [unfavContentLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(favoribleTitleLb);
        make.top.equalTo(unfavoribleTitleLb.mas_bottom).offset(5);
        make.right.mas_equalTo(-10);
        make.bottom.equalTo(bgView.mas_bottom).offset(-20);
    }];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)updateContent:(NSArray *)favContentArray unfav:(NSArray *)unfavContentArray {
    NSString *favContent = [favContentArray componentsJoinedByString:@"\n"];
    NSString *unFavContent = [unfavContentArray componentsJoinedByString:@"\n"];
    
    self.favContentLb.text = favContent;
    self.unfavContentLb.text = unFavContent;
}

@end
